package com.bear.sgg.springboot_11_cache.service;

import com.bear.sgg.springboot_11_cache.entity.Department;
import com.bear.sgg.springboot_11_cache.mapper.DepartmentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

/**
 * @ClassNmae DepartmentService
 * @Description TODO
 * @Author bear
 * @Date 2020/3/17 0017 上午 9:37
 */
@Service
public class DepartmentService {

    @Autowired
    DepartmentMapper departmentMapper;

    @Cacheable(cacheNames = "dept", key = "#id")
    public Department selectDeptById(Integer id) {
        return departmentMapper.selectDeptById(id);
    }

    @CachePut(cacheNames = "dept", keyGenerator = "myKeyGenerator2")
    public int insertDpet(Department department) {
        return departmentMapper.insertDept(department);
    }
}
